package com.sxit.myproscenium.system.controller;

import com.sxit.myproscenium.common.response.R;
import com.sxit.myproscenium.system.entity.Category;
import com.sxit.myproscenium.system.service.ICategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 前端控制器
 *
 * @author wcn
 * @since 2022-04-10
 */
@RestController
@RequestMapping("/system/category")
public class CategoryController {

  @Autowired private ICategoryService categoryService;

  /**
   * 获取所以的二级分类
   *
   * @return
   */
  @GetMapping("/getCategoryList")
  public R getCategories() {
    List<Category> list = categoryService.getCategoriesByMyself();
    return R.ok().put("data", list);
  }

  @GetMapping("/getAllCategoryList")
  public R getAllCategoryList() {
    List<Category> list = categoryService.getAllCategoryList();
    return R.ok().put("data", list);
  }
}
